<!-- Sidebar Menu -->
<nav class="mt-2">
  <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
    <!-- Add icons to the links using the .nav-icon class
         with font-awesome or any other icon font library -->
    <li class="nav-item">
      <a href="javascript:void(0);" class="nav-link" onclick="revoke()">
        <i class="nav-icon fas fa-circle"></i>
        <p>撤销15天以上订单</p>
      </a>
    </li>
    <li class="nav-item" id="info-mod-menu-open">
      <a href="edit_person_info" class="nav-link" id="info-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>个人信息</p>
      </a>
    </li>
    <li class="nav-item" id="order-mod-menu-open">
      <a href="javascript:void(0);" class="nav-link" id="order-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>
          订单列表
          <i class="right fas fa-angle-left"></i>
        </p>
      </a>
      <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="copywrite_list" class="nav-link" id="copywrite-order-list">
            <i class="far fa-circle nav-icon"></i>
            <p>文案订单</p>
          </a>
        </li>
        <li class="nav-item">
          <a href="clip_list?p=1" class="nav-link" id="clip-order-list">
            <i class="far fa-circle nav-icon"></i>
            <p>剪辑订单</p>
          </a>
        </li>
        <li class="nav-item">
          <a href="order_history_list?p=1" class="nav-link" id="order-history-list">
            <i class="far fa-circle nav-icon"></i>
            <p>订单历史</p>
          </a>
        </li>
      </ul>
    </li>
    <li class="nav-item" id="task-mod-menu-open">
      <a href="task_list?p=1" class="nav-link" id="task-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>任务列表</p>
      </a>
    </li>
    <li class="nav-item" id="topic-mod-menu-open">
      <a href="topic_list?p=1" class="nav-link" id="topic-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>选题列表</p>
      </a>
    </li>
    <li class="nav-item" id="spread-mod-menu-open">
      <a href="spread_list?p=1" class="nav-link" id="spread-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>推广列表</p>
      </a>
    </li>
    <li class="nav-item" id="group-mod-menu-open">
      <a href="group_list?p=1" class="nav-link" id="group-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>小组列表</p>
      </a>
    </li>
    <li class="nav-item" id="publish-mod-menu-open">
      <a href="javascript:void(0);" class="nav-link" id="publish-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>
          发布列表
          <i class="right fas fa-angle-left"></i>
        </p>
      </a>
      <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="unpublish_list?p=1" class="nav-link" id="unpublish-list">
            <i class="far fa-circle nav-icon"></i>
            <p>待发布</p>
          </a>
        </li>
        <li class="nav-item">
          <a href="publish_list?p=1" class="nav-link" id="publish-list">
            <i class="far fa-circle nav-icon"></i>
            <p>已发布</p>
          </a>
        </li>
      </ul>
    </li>
    <li class="nav-item" id="msg-mod-menu-open">
      <a href="javascript:void(0);" class="nav-link" id="msg-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>
          留言
          <i class="right fas fa-angle-left"></i>
          <span class="badge badge-danger right" id="msg_new1" style="display: {new_display};">new</span>
        </p>
      </a>
      <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="own_msg_list?p=1" class="nav-link" id="own-msg-list">
            <i class="far fa-circle nav-icon"></i>
            <p>我发送的</p>
          </a>
        </li>
        <li class="nav-item">
          <a href="receive_msg_list?p=1" class="nav-link" id="receive-msg-list">
            <i class="far fa-circle nav-icon"></i>
            <p>接收到的</p>
            <span class="badge badge-danger right" id="msg_new2" style="display: {new_display};">new</span>
          </a>
        </li>
      </ul>
    </li>
    <li class="nav-item" id="examine-mod-menu-open">
      <a href="wait_for_examine?p=1" class="nav-link" id="examine-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>审核列表</p>
      </a>
    </li>
    <li class="nav-item" id="user-mod-menu-open">
      <a href="javascript:void(0);" class="nav-link" id="user-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>
          用户管理
          <i class="right fas fa-angle-left"></i>
        </p>
      </a>
      <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="user_list?p=1" class="nav-link" id="user-list">
            <i class="far fa-circle nav-icon"></i>
            <p>用户</p>
          </a>
        </li>
        <li class="nav-item">
          <a href="admin_list?p=1" class="nav-link" id="admin-user-list">
            <i class="far fa-circle nav-icon"></i>
            <p>管理员</p>
          </a>
        </li>
      </ul>
    </li>
    <li class="nav-item" id="superadmin-mod-menu-open">
      <a href="javascript:void(0);" class="nav-link" id="superadmin-mod">
        <i class="nav-icon fas fa-circle"></i>
        <p>
          超级管理员
          <i class="right fas fa-angle-left"></i>
        </p>
      </a>
      <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="edit_global" class="nav-link" id="superadmin-global-list">
            <i class="far fa-circle nav-icon"></i>
            <p>网站全局</p>
          </a>
        </li>
      </ul>
    </li>
  </ul>
</nav>
<script type="text/javascript">
  if (ws !== null) {
    ws.addEventListener('message', function (event) {
      var kv = str2kv(event.data);
      var data = event.data;
      if (kv['msg'] !== undefined && kv['msg'].indexOf('"-"') !== -1) {
        var msg_kv = kv['msg'].split('"-"');
        if (msg_kv[0] === 'msg') {
          $.post('{base_url}ws_lib/menu', function (data) {
            var count = parseInt(data);
            if (count > 0) {
              $('#msg_new1').show();
              $('#msg_new2').show();
            } else {
              $('#msg_new1').hide();
              $('#msg_new2').hide();
            }
          });
        }
      } else if (data.indexOf(':') !== -1) {
        var d = data.split(':');
        if (d[0] === 'fail') {
          layer.alert('系统错误，' + d[1], {icon:2});
          return;
        }
      }
    });
  }
  $(function () {
    $('#{mod_id}').addClass('active');
    $('#{mod_menu_open}').addClass('menu-open');
    {sub_mod_id}
  });

  var revoke_index = null;
  function revoke() {
    revoke_index = layer.load(1);
    $.ajax({
      url: '{base_url}library/revoke_15day',
      type: 'post',
      success: function (data) {
        var value = parseInt(data);
        layer.alert('已撤销' + value + '条订单', {icon: 1});
        layer.close(revoke_index);
        if (ws !== null && ws.readyState === 1) {
          ws.send('receive_id"="0";"msg"="msg"-"task_list');
          ws.send('receive_id"="0";"msg"="msg"-"copywrite_list');
          ws.send('receive_id"="0";"msg"="msg"-"clip_list');
        }
      }
    });
  }
</script>
<!-- /.sidebar-menu -->
